﻿//=====================================================================================================
// LocalizationLibrary
// The Localization Library is a collection of reusable software components that provide 
// support for localization. This library enables you to localize WPF, Silverlight and WP7 applications.
// (http://localizationlibrary.codeplex.com)
//=====================================================================================================
// Author: Nicola Gallo (Website: www.nicola.gallo.name, Email: nicolagmt@hotmail.it) 
//=====================================================================================================

namespace LocalizationLibrary.Tests.Core.Reflection
{
    //.NET References
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Reflection;
    using System.Runtime.Serialization;
    using System.Text;

    //LocalizationLibrary References
    using DeployPackA.Tests.LocalizationModels;
    using LocalizationLibrary.Attributes;
    using LocalizationLibrary.Reflection;
    using LocalizationLibrary.Tests.Infrastructure;

    //Microsoft References
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class AssemblyManagerTest
    {
        [TestMethod]
        public void Publish_Assembly_Shoud_Publish()
        {
            using (LocalizationLibraryContext llContext = new LocalizationLibraryContext(true))
            {
                //Resets current context.
                llContext.Reset();

                bool published = false;
                Assembly assembly = Assembly.GetCallingAssembly();
                AssemblyManager.AssemblyLoaded += (_sender, _e) =>
                {
                    if ((_sender.Equals(typeof(AssemblyManager).FullName)) && (_e.Assembly == assembly))
                    {
                        published = true;
                    }
                };
                AssemblyManager.PublishAssemblyLoaded(null);
                Assert.AreEqual(published, false);
                AssemblyManager.PublishAssemblyLoaded(assembly);
                Assert.AreEqual(published, true);
            }
        }
    }
}
